package com.moon;

import com.moon.dao.TAuctionMapper;
import com.moon.es.ESTAuctionDataWriter;
import com.moon.es.ESTAuctionRepository;
import com.moon.vo.TAuctionVo;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;

import java.util.List;

@SpringBootTest
public class EStest {
    @Autowired
    ESTAuctionRepository estAuctionRepository;
    @Autowired
    ESTAuctionDataWriter estAuctionDataWriter;
    @Autowired
    ElasticsearchRestTemplate elasticsearchRestTemplate;
    @Autowired
    TAuctionMapper tAuctionMapper;

    //创建或更新es索引库
    @Test
    void updateES(){
//        elasticsearchRestTemplate.deleteIndex("estauction");
        estAuctionRepository.deleteAll();
//        List<TAuctionVo> tAuctionVos = tAuctionMapper.selectAllTAuctionVo();
        estAuctionDataWriter.dataWrite();
    }

    //删除es索引库
    @Test
    void deleteEs(){
        elasticsearchRestTemplate.deleteIndex("estauction");
    }

}
